Introduction
I got this brand new phone with integrated email
client. And as we know mobile email checking costs money.But then I
stumbled upon one of those free sms internet gateways. So the idea was to
write simple program to check / read email (
see my
article) and then forward it as sms text to my mobile. But of course
nothing keeps you from let's say reading some rss feed or stock value from
web and sending it as sms to your mobile. Also there are some mms internet
gateways too (
like) so you
can for example send image from your webcam (
see my
article) right to your mms capable mobile when you detect movement in
your room
Background
Well most of these sms gateways are simple web forms.
and some of them require login prior sending. but this is not a problem
since this is just another web form.
How to Post Web Form
I tried to find simplest way how to do this.
Beware the folowing sample will work just for sending one free sms Save
the following code as let's say form.htm. And That's it. Doubleclicking it
will send 1 free sms. But before you do so be sure you replace the country
phone prefix "421" and mobile phone number "902203302".
<script language="JavaScript"><!--
var input = new Array("user_reg", "email_reg","mobile_code_reg","mobile_reg","reg");
var value = new Array("HelloWorld", "o@o.o", "421", "902203302", "1");
document.write("<body><form name=form method=POST action=http://www.etssms.com/globindex.php?show_page=register>")
for (i in input) document.write("<input type=hidden name="+input[i]+" value="+value[i]+">")
document.write("</form>")
form.submit();
How to do this from your program
Well in any language on any
platform just open this htm file(or have it as static string or resource.
and replace "Hello World" "421" "902203302" with your values then write it
to tmp.htm file and launch it from shell. Voila all proxy negotiation url
redirection ssl encryption urlencoding auth cookie and final form size
calculation etc. is done by default by web browser transparently for us.
#include <windows.h>
#include <stdio.h>
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, char* cmd, int show) {
char data[2][0x1000]={0};
FILE* file=fopen("form.htm","rb"); fread( data[0],1,sizeof(data[0]),file); fclose(file);
sprintf(data[1],data[0],"HelloWorld","o@o.o","421","902203301","1");
file=fopen("send.htm","wb"); fwrite(data[1],1,strlen(data[1]),file); fclose(file);
ShellExecute(0,"open","send.htm",0,0,SW_HIDE);
}
Place for Improvements
One reason why I din't used internet
explorer wininet.dll or browser com hosting is to make this solution
multiplatfom and multilanguage. Also latest patches to internet explorer
(XP SP2) require interactive confirmation to every javascript in html. One
solution is to add localhost to trusted sites in internet explorer
security zones options or send 2 mouse clicks to ie window so action is
confirmed. I personaly prefer firefox as default browser. Later you will
also want to run browser window hidden and close it when finished but that
shouldn't be a problem.(will add code for this later)
There are many mobile providers and sms gateways
Just to mention
few (agentsms.com SMS.ac, ETS SMS, smsGeezer.com, Bigfoot.com,
Weltweite-SMS.de GoogleCalendar) So go and chose one. Next find fields
names by viewing page source in browser when there. And finally write new
form.htm for this gateway + update your exe to fill this new form